﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using NetLib;
using System.Windows.Input;
using GUILib;
using Newtonsoft.Json;
using System.Diagnostics;
using MetaTracker.Model;
//using fatsecret.platform;



namespace MetaTracker.ViewModel
{
    internal class MainViewModel : TrackerBaseViewModel
    {
        #region Data and Properties
        //private RESTProcessor Proc;

        public const string URL_BASE = "http://platform.fatsecret.com/rest/server.api?";

        //private TrackerModel tracker;

        #endregion //Data and Properties

        #region Contstructors

        public MainViewModel()
        {
            //Proc = new RESTProcessor();

            tracker.PropertyChanged += new System.ComponentModel.PropertyChangedEventHandler(tracker_PropertyChanged);

        }

        void tracker_PropertyChanged(object sender, System.ComponentModel.PropertyChangedEventArgs e)
        {
            NotifyPropertyChanged(e.PropertyName);
        }

        #endregion //Contstructors

        #region Commands and Command Methods

        

        #endregion //Commands and Command Methods

        #region Methods
        #endregion //Methods
    }

    public class statusobject
    {
        public int Status;
    }
    public class WithingsGetByUserIDResult
    {
        public int Status;
        public WithingsGetByUserIDResultBody body;
    }
    public class WithingsGetByUserIDResultBody
    {
        //public WithingsGetByUserIDResultBodyUsers users;
        //public Dictionary<string, string> Users;
        public object[] users;
    }
    public class WithingsGetByUserIDResultBodyUsers
    {
        public int id;
        public string firstname;
        public string lastname;
        public string shortname;
        public string gender;
        public int fatmethod;
        public int birthdate;
        public bool ispublic;

    }

    public class WithingsMeasurmentResult
    {
        public int Status;
        public WIthingsMeasurementResultBody body;
    }
    public class WIthingsMeasurementResultBody
    {
        public WIthingsMeasurementResultBodyMeasurGrps[] measuregrps;
    }
    public class WIthingsMeasurementResultBodyMeasurGrps
    {
        public int grpid;
        public int attrib;
        public Int64 date;
        public int category;
        public WIthingsMeasurementResultBodyMeasurGrpsMeasures[] measures;

        public override string ToString()
        {
            DateTime day = new DateTime(1970, 1, 1);
            day.AddDays(date);
            return day.ToString("s");
        }
        public DateTime GimmeADateTime()
        {
            DateTime day = new DateTime(1970, 1, 1);
            day = day.AddSeconds(date);
            return day;
        }


    }
    public class WIthingsMeasurementResultBodyMeasurGrpsMeasures
    {
        public int value;
        public int type;
        public int unit;

        public override string ToString()
        {
            return
                ((double)value * Math.Pow(10.0, (double)unit) * 2.20462262).ToString()
                + " lbs";
                
        }
        public double GimmeAWeightInPounds()
        {
            return
                ((double)value * Math.Pow(10.0, (double)unit) * 2.20462262);
        }
    }

    public class Result
    {
        public DateTime Date;
        public double Weight;

        public Result()
        {
        }
        public Result(DateTime date, double weight)
        {
            Date = date;
            Weight = weight;
        }
        public override string ToString()
        {
            return Date.ToString("s") + " " + Weight + " lbs";
        }
    }

}
